<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$_LangPath = 'innerindex';	//語言檔參數，務必放在最前面
include_once("../config.inc.php");
session_start();
include_once(__Member_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_member.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Modules_Path."/Lotto.lib.php");

$objMember = $_SESSION["Member_Info"];
$intLID = (int)$_data["LottoID"];
if(empty($intLID)){
	$intLID = (defined('__MemInitLottoID'))?__MemInitLottoID:1;
	if(empty($intLID))$intLID = 1;
}



$fp = @file(__Root_Path."/indexpage/index_member.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);
$fp = str_replace("{UserID}", $_SESSION["Member_Info"] -> ID, $fp);
$fp = str_replace("{time}", "103", $fp);
$fp = str_replace("{sid}", $_data["sid"], $fp);
$fp = str_replace("../membertemplate/", "", $fp);
$fp = str_replace(".html?", ".php?", $fp);
$fp = str_replace("{LID}", $intLID, $fp);

$strLCon = "";
$arrLottoPower = getLottoUsePowerArray($objMember -> GamePower);
sort($arrLottoPower);

preg_match("/<!-- Lotto@bof \/\/-->(.+)<!-- Lotto@eof \/\/-->/s", $fp, $arrLCon);
foreach($arrLottoPower as $intLottoID){
	$strTmp = $arrLCon[1];

	$arrLotto = $_arrLotto[$intLottoID];
	$strTmp = str_replace("{Lotto}", $arrLotto["Lotto_".$_intLang], $strTmp);
	$strTmp = str_replace("{ItemLID}", $intLottoID, $strTmp);

	if($intLottoID == $intLID){
		$fp = str_replace("{NowLotto}", $arrLotto["Lotto_".$_intLang], $fp);
		$fp = str_replace("{NowLID}", $intLID, $fp);
		$strTmp = str_replace("noneclass", "lottofocus", $strTmp);
	}
	$strLCon .= $strTmp."\n";
}
$fp = preg_replace("/<!-- Lotto@bof \/\/-->.+<!-- Lotto@eof \/\/-->/s", $strLCon, $fp);

switch($intLID){
	case 2:
	case 3:
	case 6:
	case 7:
	case 8:
		$fp = str_replace("specialnumber_o", "number51", $fp);
		break;

	case 4:
		$fp = str_replace("specialnumber_o", "7star1", $fp);
		break;

	case 5:
		$fp = str_replace("specialnumber_o", "10m1", $fp);
		break;

	default:
		$fp = str_replace("specialnumber_o", "specialnumber", $fp);
		$fp = str_replace("stype=o", "stype=c", $fp);
		break;
}

$fp = str_replace("{ShowUserAcc}", $objMember -> Account, $fp);

while(list($k, $v) = each($_strInnerIndex)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

$arrBet_Type = $_arrBet_Type[$intLID];
foreach($arrBet_Type as $intBT => $strBT){
	$_SESSION["Member_Info"] -> arrEventLimit[$intLID][$intBT] = 99999999;
	$_SESSION["Member_Info"] -> arrBetLimit[$intLID][$intBT] = 99999999;
}

//從平台取得以使用信用額度  退水參數  各階層成數 
$objUData = getPFMemberUCreditParamScale($_SESSION["Member_PFSID"], $objMember, $intLID);
if($objUData === false)ErrMsgOutputHTML("Error", "", 1);

//載入退水
$arrComm = getPFMemberParamToLotto($intLID, $objMember -> Game_Type, (array)$objUData -> ParamInfo);
$_SESSION["Member_Info"] -> arrCommission[1] = $arrComm[$objMember -> ID];
$_SESSION["Member_Info"] -> arrCommission[2] = $arrComm[$objMember -> SubID];
$_SESSION["Member_Info"] -> arrCommission[3] = $arrComm[$objMember -> MainID];
$_SESSION["Member_Info"] -> arrCommission[4] = $arrComm[$objMember -> StockID];
$_SESSION["Member_Info"] -> arrCommission[5] = $arrComm[$objMember -> DirectorID];
$_SESSION["Member_Info"] -> arrCommission[6] = $arrComm[$objMember -> Layer6ID];

if($objMember -> Game_Type != 1){
	$arrComm = getPFMemberParamToLotto($intLID, 1, (array)$objUData -> ParamInfo);
}
$_SESSION["Member_Info"] -> arrCommissionA = $arrComm;

//載入成數
$arrScale = getPFMemberScaleToLotto($objMember, (array)$objUData -> PreScale);
if($arrScale === false)ErrMsgOutputHTML("Scale To Lotto Error", "", 1);

$_SESSION["Member_Info"] -> SubScale = $arrScale[1][2];
$_SESSION["Member_Info"] -> MainScale = $arrScale[1][3];
$_SESSION["Member_Info"] -> StockScale = $arrScale[1][4];
$_SESSION["Member_Info"] -> DirectorScale = $arrScale[1][5];
$_SESSION["Member_Info"] -> Layer6Scale = $arrScale[1][6];
$_SESSION["Member_Info"] -> LayerScale = $arrScale;


//取得各階層自動向上限額
$arrAcceptLimit = array();
$arrIsAutoSupple = array();
$strSQL = "select * from `bet_MemberLimit` where MemID in (".$objMember -> SubID.",".$objMember -> MainID.",".$objMember -> StockID.",".$objMember -> DirectorID.",".$objMember -> Layer6ID.") and LimitType in (3) ";
if(!$RS = PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = $_strLogin["NoCommission"]."2";  //"會員資料錯誤，其退水尚未設定！"
	ErrMsgOutputHTML("Error", "", 1);
}
while($Rows = PMA_mysql_fetch_object($RS)){
	if($Rows -> LottoID == 0 && $Rows -> Bet_Type == 1){
		$arrIsAutoSupple[$Rows -> MemID] = ($Rows -> LimitValue != 1)?0:1;
	}elseif($Rows -> LimitType == 3){
		$arrAutoSuppleLimit[$Rows -> LottoID][$Rows -> Bet_Type][$Rows -> MemID] = $Rows -> LimitValue;
	}
}
$_SESSION["Member_Info"] -> arrAutoSuppleLimit = $arrAutoSuppleLimit;
$_SESSION["Member_Info"] -> SubIsAutoSuppl = $arrIsAutoSupple[$Rows -> SubID];
$_SESSION["Member_Info"] -> MainIsAutoSuppl = $arrIsAutoSupple[$Rows -> MainID];
$_SESSION["Member_Info"] -> StockIsAutoSupple = $arrIsAutoSupple[$Rows -> StockID];
$_SESSION["Member_Info"] -> DirectorIsAutoSuppl = $arrIsAutoSupple[$Rows -> DirectorID];
$_SESSION["Member_Info"] -> Layer6IsAutoSupple = $arrIsAutoSupple[$Rows -> Layer6ID];



$intBalenceCredit = number_format($_SESSION["Member_Info"] -> CreditLine + $objUData -> UsedCredit);
$fp = str_replace("{ShowCredit}", $intBalenceCredit, $fp);

//輸出
WebOutputHTML($fp, 1);
?>